package com.syl.practice.globalexception.controller;

import com.syl.practice.globalexception.dto.User;
import com.syl.practice.globalexception.result.ApiResult;
import com.syl.practice.globalexception.service.ApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/exc")
public class ExceptionController {

    @Autowired
    ApiService apiService;

    @RequestMapping("/test01")
    public ApiResult test01(){
        ApiResult<User> response = new ApiResult();
        User user = new User(1,"平安");
        response.setData(user);
        return response;
    }

    @RequestMapping("/test02")
    public ApiResult test02(){
        ApiResult<User> response = new ApiResult();
        User user = apiService.getUser();
        response.setData(user);
        return response;
    }

    @RequestMapping("/test03")
    public ApiResult test03(){
        ApiResult<User> response = new ApiResult();
        User user = apiService.getUser();
        response.setData(user);
        return response;
    }
}
